package com.example.nfctagcommons.classes;

import java.util.HashMap;

import android.app.Activity;

import com.example.nfctagcommons.exceptions.ConnectivityException;
import com.example.nfctagcommons.server.ServerConnector;

//SINGLETON
public class VigilanceSet {
	private HashMap<String, VigilancePoint> watchList;
	private static VigilanceSet instance;
	
	public static VigilanceSet getInstance(Activity activity, String deviceId){
		if (instance == null){
			instance = new VigilanceSet(activity, deviceId);
		}
		return instance;
	}

	private VigilanceSet() {
		
	}

	private VigilanceSet(Activity activity, String deviceId) {
		try {
			this.watchList = ServerConnector.getVigilanceSet(activity,deviceId);
		} catch (ConnectivityException e) {
			e.printStackTrace();
		}
	}

	public HashMap<String, VigilancePoint> getVigilanceSet(){
		return watchList;
	}
	
	public VigilancePoint getLocal(String localId){
		return watchList.get(localId);
	}
	
	public void setLocalChecked(Activity activity, String guardId, String localId, String checkComments, long time) throws ConnectivityException{
		ServerConnector.setLocalChecked(activity,guardId, localId, checkComments, time);
	}
}
